package com.hgy.plugin.security.tag;

import java.util.Arrays;

import org.apache.shiro.subject.Subject;
import org.apache.shiro.web.tags.RoleTag;

public class HasAllRolesTag extends RoleTag {

    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;

    private static final String ROLE_NAMES_DELIMETER = ",";

    public HasAllRolesTag() {
    }

    protected boolean showTagBody(String roleNames) {
        boolean hashAllRole = false;

        Subject subject = getSubject();

        if (subject != null) {
        	if(subject.hasAllRoles(Arrays.asList(roleNames.split(ROLE_NAMES_DELIMETER)))){
        		hashAllRole = true;
        	}
        }
        return hashAllRole;
    }

}
